<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class AbstractPage extends CI_Controller {

    public function __construct()
    {
            parent::__construct();
            $this->load->library('session');
    }

    public function index()
    {
        $this->checkLogin();
        $this->load->model('Notifikasikegiatan','notifikasi');        
        $data = array('abstractPage' => $this); //kirim objek AbstractPage ke viewer agar viewer dapat memanggil fungsi load_header(),load_side_menu(), dan _build_content()
        $data['sess_pengguna'] = $this->session->userdata('pengguna');
        $data['notifikasi'] = $this->notifikasi->getUnreaded($data['sess_pengguna']['userID']);
        $this->load->view('template/template_page', $data);
    }

    public function load_header()
    {
        $this->load->view('template/header');
    }

    public function load_side_menu()
    {
        $this->load->view('template/side_menu');
    }
    /*override method ini*/
    function _buildcontent()
    {
        //Silakan override method _buildContent() pada kelas Controller untuk mengisi panel content
    }

    function checkLogin(){
        $pengguna = $this->session->userdata('pengguna');
        if($this->uri->segment(1)!= 'login' && empty($pengguna)){
                redirect('/login/in');
        }
    }
}
